<?php
/**
 * Description of Database
 *
 * @author Jose Arcos
 */
include_once 'config.php';
class Database
{

    const DB_HOSTNAME = DB_HOSTNAME;
    const DB_USER = DB_USER;
    const DB_PASS = DB_PASS;
    const DB_NAME = DB_NAME;

    private $_connection;
    private static $_instance;


    public static function getInstance()
    {
        if ( !self::$_instance ) { 
            self::$_instance = new self();
        }
        return self::$_instance;
    }

    private function __construct()
    {
        $this->_connection = new mysqli(self::DB_HOSTNAME,  
                                        self::DB_USER,  
                                        self::DB_PASS,  
                                        self::DB_NAME);

        if ( mysqli_connect_error() ) {
            trigger_error( "Failed to conencto to MySQL: " . mysqli_connect_error(), E_USER_ERROR );
        }
    }

    private function __clone()
    {
        
    }

    public function getConnection()
    {
        return $this->_connection;
    }
}